package com.woniuxy.amusementparkos.service.lsy.impl;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.woniuxy.amusementparkos.dao.lsy.PosDao;
import com.woniuxy.amusementparkos.entity.lsy.Pos;
import com.woniuxy.amusementparkos.exception.ObjectNotExistException;
import com.woniuxy.amusementparkos.service.lsy.PosService;


//声明为服务类
/**
 * Pos机管理实现类
 * @author Muzi
 * create:2020年4月22日 17:54:55
 */
@Service
public class PosServiceImpl implements PosService {
	/**
	 * 注入Dao接口实现对象
	 */
	@Autowired
	PosDao posDao;
	
	//查询所有可用pos机
	@Override
	public List<Pos> listAllPos() {
		return posDao.listAllPos();
	}
	//通过POS机器码查找一个POS机对象
	@Override
	public Pos getOnePosById(String pos_id) {
		return posDao.getOnePosById(pos_id);
	}
	@Override
	public Pos getOnePosByPKId(Integer id) {
		return posDao.getOnePosByPKId(id);
	}
	@Override
	public List<Pos> listAllPosByCounterId(Integer counter_id) {
		return posDao.listAllPosByCounterId(counter_id);
	}
	@Override
	public List<Pos> listAllPosByOrganizationId(Integer organization_id) {
		return posDao.listAllPosByOrganizationId(organization_id);
	}
	@Override
	public void insertOnePos(Pos pos) {
		posDao.insertOnePos(pos);
		
	}
	@Override
	public void updateOnePosById(Pos pos) throws RuntimeException{
		Integer row = posDao.updateOnePosById(pos);
		if(row == 0) {
			throw new ObjectNotExistException("更新目标不存在");
		}
		
	}
	@Override
	public void deleteOnePosById(Integer id) throws RuntimeException{
		Integer row = posDao.deleteOnePosById(id);
		if(row == 0) {
			throw new ObjectNotExistException("删除目标不存在");
		}
	}
	@Override
	public Pos getByIp(String pos_ip) {
		return posDao.getByIp(pos_ip);
	}

}
